/*
package com.cx.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

*/
/**
 * @auther: Centaury
 * @Date:2023/3/22 - 03 - 22 - 14:01
 *//*

@RestController
public class JDBCController {

    @Autowired
    JdbcTemplate jdbcTemplate;

    // 增
    @GetMapping("/addStu")
    public String addStu(){
        String sql = "insert into " +
                "student(id,name,birth,score,major,telephone)" +
                " value(1001,'Centaury','2000-4-13','90','汉语言文学','13141939068')";
        jdbcTemplate.update(sql);
        return "add-ok";
    }
    // 删
    @GetMapping("/deleteStu/{id}")
    public String delStu(@PathVariable("id")Integer id){
        String sql = "delete from student where id=?";
        jdbcTemplate.update(sql,id);
        return "delete-ok";
    }
    // 改
    @GetMapping("/updateStu/{id}")
    public String updateStu(@PathVariable("id")Integer id){
        String sql = "update student set name=?,score=? where id="+id;

        // 封装
        Object [] objects = new Object[2];
        objects[0] = "矢车菊";
        objects[1] = 99;
        jdbcTemplate.update(sql,objects);
        return "update-ok";
    }
    //查
    @GetMapping("/stuList")
    public List<Map<String,Object>> userList(){
        String sql = "select * from student";
        List<Map<String, Object>> list_maps = jdbcTemplate.queryForList(sql);
        return list_maps;
    }
}
*/
